"""example of how to cluster a graph based on edges curvatures"""
import pickle

import networkx as nx

from geometric_clustering import cluster_signed_modularity, load_curvature

if __name__ == "__main__":
    graph = nx.read_gpickle("graph_powergrid.gpickle")
    graph = nx.convert_node_labels_to_integers(graph)

    times, kappas = load_curvature(filename="curvature.pkl")
    times = times[:-8]
    kappas = kappas[:-8]

    cluster_results = cluster_signed_modularity(
        graph,
        times,
        kappas,
        kappa0=None,
        n_louvain=50,
        n_louvain_VI=50,
        n_workers=4,
        with_postprocessing=True,
    )
    pickle.dump(cluster_results, open("cluster_results.pkl", "wb"))
